package com.swyc.osschat.Test.OptionalTest;

import java.util.List;
import java.util.Optional;

import com.swyc.osschat.Test.LambdaTest.Bean.Student;

/**
 * @author zhaol@yunrong.cn
 * @version V2.1
 * @since 2.1.0 2019/8/13 11:15
 */
public class OptionalTest1 {
    private static final List<Student> students = Student.generateData();
    public static void main(String[] args) {
        OptionalTest1 test = new OptionalTest1();
        Student student1 = null;
        Student student2 = students.get(2);
        Optional<Student> optionalStudent1 = Optional.ofNullable(student1);
        Optional<Student> optionalStudent2 = Optional.ofNullable(student2);
        System.out.println(test.sum(optionalStudent1,optionalStudent2));
    }
    public String  sum(Optional<Student> a, Optional<Student> b){
        System.out.println("第一个参数值存在: " + a.isPresent());
        System.out.println("第二个参数值存在: " + b.isPresent());
        Student student1 = a.orElse(students.get(1));
        Student student2 = b.get();
        return Student.beanToString(student1)+"<->"+Student.beanToString(student2);
    }
}
